package com.spic.business.hidden.management.controller;

import com.spic.business.common.core.utils.poi.BusinessExcelUtil;
import com.spic.business.hidden.management.domain.HiddenLibraryManagement;
import com.spic.business.hidden.management.service.IHiddenLibraryManagementService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
 * 排查清单库管理Controller
 *
 * @author spic
 * @date 2021-10-15
 */
@RestController
@RequestMapping("/hidden/management")
public class HiddenLibraryManagementController extends BaseController
{
    @Autowired
    private IHiddenLibraryManagementService hiddenLibraryManagementService;

    /**
     * 查询排查清单库管理列表
     */
    @PreAuthorize(hasPermi = "business/hidden:management:list")
    @GetMapping("/list")
    public TableDataInfo list(HiddenLibraryManagement hiddenLibraryManagement)
    {
        startPage();
        List<HiddenLibraryManagement> list = hiddenLibraryManagementService.selectHiddenLibraryManagementList(hiddenLibraryManagement);
        return getDataTable(list);
    }

    /**
     * 导出排查清单库管理列表
     */
    @PreAuthorize(hasPermi = "business/hidden:management:export")
    @Log(title = "排查清单库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HiddenLibraryManagement hiddenLibraryManagement) throws IOException
    {
        List<HiddenLibraryManagement> list = hiddenLibraryManagementService.selectHiddenLibraryManagementList(hiddenLibraryManagement);
        ExcelUtil<HiddenLibraryManagement> util = new BusinessExcelUtil<HiddenLibraryManagement>(HiddenLibraryManagement.class);
        util.exportExcel(response, list, "排查清单库管理数据");
    }

    /**
     * 获取排查清单库管理详细信息
     */
    @PreAuthorize(hasPermi = "business/hidden:management:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hiddenLibraryManagementService.selectHiddenLibraryManagementById(id));
    }

    /**
     * 新增排查清单库管理
     */
    @PreAuthorize(hasPermi = "business/hidden:management:add")
    @Log(title = "排查清单库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HiddenLibraryManagement hiddenLibraryManagement)
    {
        return toAjax(hiddenLibraryManagementService.insertHiddenLibraryManagement(hiddenLibraryManagement));
    }

    /**
     * 修改排查清单库管理
     */
    @PreAuthorize(hasPermi = "business/hidden:management:edit")
    @Log(title = "排查清单库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HiddenLibraryManagement hiddenLibraryManagement)
    {
        return toAjax(hiddenLibraryManagementService.updateHiddenLibraryManagement(hiddenLibraryManagement));
    }

    /**
     * 删除排查清单库管理
     */
    @PreAuthorize(hasPermi = "business/hidden:management:remove")
    @Log(title = "排查清单库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hiddenLibraryManagementService.deleteHiddenLibraryManagementByIds(ids));
    }
}
